package com.sprint.service.impl;

import com.sprint.dao.AccountDao;
import com.sprint.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.concurrent.TimeUnit;

@Service
@Slf4j
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;

    @Override
    public void decrease(Long userId, BigDecimal money) {
        log.info("---------AccountServiceImpl 账户余额服务 中扣减库存开始");
        try {
            TimeUnit.SECONDS.sleep(10);
        }
        catch (InterruptedException e)
        { e.printStackTrace();
        }
        accountDao.decrease(userId, money);
        log.info("---------AccountServiceImpl 账户余额服务 中扣减库存结束");
    }
}
